<template>
  <div class="monitor-box">
    <CardBox title="统计"> </CardBox>
    <div class="content-container">
      <div class="statistics-chart" ref="speciesChart"></div>
    </div>
  </div>
</template>
<script>
import CardBox from "@/components/Global/CardBox.vue";
import {EventBus} from "../../utils/event-bus";
import * as echarts from "echarts";

export default {
  name: "Introduce",
  components: {
    CardBox,
  },
  data() {
    return {
      introduce:'',
    };
  },
  created() {
    EventBus.$on('set-multi-introduce', (message) => {
      this.introduce=message;
    });
  },
  mounted() {
    this.$api.species.getSpeciesTree("鸟类").then(res => {
      this.initChart(res)
    });
  },
  methods: {
    initChart(data) {
      const chartDom = this.$refs.speciesChart
      if (!chartDom) return

      const chart = echarts.init(chartDom)
      for (let i = 0; i < data.length; i++) {
        data[i].label= {
          minAngle: 5
        }
      }
      const option = {
        series: {
          type: 'sunburst',
          data: data,
          radius: [0, '96%'],
          label: {
            rotate: 'radial'
          }
        }
      }
      chart.setOption(option);
    }
  }
};
</script>

<style lang="scss" scoped>

.statistics-chart {
  width: 100%;
  height: 100%;
}
  .content-container{
    height: 500px;
  }
</style>